import java.util.function.IntUnaryOperator;
import java.util.function.IntToDoubleFunction;
import java.util.Comparator;
import java.util.Arrays;

public class ArraysAPI {
    public static void main(String[] args) {
        double[] arr = new double[]{1.0,2.0,9,4.0,5.0};

        //第一代的样子
/*        Arrays.setAll(arr, new IntToDoubleFunction() {
            @Override
            public double applyAsDouble(int value) {
                return arr[value] * 0.8;
            }
        });*/

        //带二代的样子
/*        Arrays.setAll(arr, (int value) ->{
                return arr[value] * 0.8;
            });*/

        //第三代的样子
        Arrays.setAll(arr,value ->arr[value] * 0.8 );
        System.out.println(Arrays.toString(arr));

    }
}

/*    public static void main(String[] args) {
        Student[] students = new Student[4];
        students[0] = new Student("张三",32);
        students[1] = new Student("李四",21);
        students[2] = new Student("王五",20);
        students[3] = new Student("赵六",22);

*//*        Arrays.sort(students, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                if (o1.getAge()> o2.getAge()){
                    return 1;
                } else if (o1.getAge()< o2.getAge()) {
                    return -1;
                }
                return 0;
            }
        });*//*
        Arrays.sort(students,(Student o1, Student o2)-> {
                if (o1.getAge()> o2.getAge()){
                    return 1;
                } else if (o1.getAge()< o2.getAge()) {
                    return -1;
                }
                return 0;
            });
        System.out.println(Arrays.toString(students));
    }
}*/
/*    public static void main(String[] args) {
        int[] arr = new int[]{5,4,3,2,1};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

    }
}*/

/*    public static void main(String[] args) {
      double[] arr = new double[]{1.0, 2, 9, 4, 5};
        Arrays.setAll(arr,new IntToDoubleFunction(){
            @Override
            public double applyAsDouble(int value) {
                return arr[value] * 0.8;
            }
        });
        System.out.println(Arrays.toString(arr));
    }
}*/
/*    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5};
        int[] arr1 = Arrays.copyOf(arr,3);
        System.out.println(Arrays.toString(arr1));
    }
}*/
/*    public static void main(String[] args) {
            int[] arr = new int[]{1,2,3,4,5};
            int[] arr1 = Arrays.copyOfRange(arr,0,6);
        System.out.println(Arrays.toString(arr1));
    }
}*/
/*    public static void main(String[] args) {
        int[] arr = new int[]{1,2,3,4,5};
        //调用静态方法
        String str = Arrays.toString(arr);
        System.out.println(str);
    }
}*/
